<?php

$_POST[change]='Checked in : '.$_POST[change];

$result = mysql_query("SELECT * FROM tblkbdocuments WHERE DocNumber='$_GET[doc]'");
$row = mysql_fetch_array($result);
$docname=$row[Document];
if($row[Out]=='true' AND $row[User]==$user)
{
$docrev=$row[Rev]+1;

$query="UPDATE tblkbdocuments SET `Out`='' , Rev='$docrev' , User='' WHERE DocNumber='$_GET[doc]'";
mysql_query($query);
$query="INSERT INTO tblkblog (DocNumber,Date,Time,`Change`,User,Rev) VALUES ('$_GET[doc]','$date','$time','$_POST[change]','$user','$docrev')";
mysql_query($query);
echo '<center><h3>Document checked in</h3><br><a href="index.php?p=kb">Back</a>';
echo '<p>'.$query;
$_POST[mail]='kbcheckin';
require_once "Common/mail.php";

}
else
{

if($row[Out]!='true')
{
echo '<center><h3>Document ';
echo 'not checked out!</h3><br><a href="index.php?p=kb">Back</a>';
}
else if($row[User]!=$user)
{
echo $row[User].' Needs to check document in</h3><br><a href="index.php?p=kb">Back</a>';
}
}
?>
